const servesRes = async (ctx, apis) => {
  if (ctx.method === "GET") {
    const res = await apis(ctx);
    ctx.body =
      res.code === 200
        ? {
            success: true,
            code: res?.code,
            data: res.data,
            message: "成功",
          }
        : {
            success: true,
            code: res?.code,
            data: null,
            message: "查询失败",
          };
  } else {
    const res = await apis(ctx);
    ctx.body =
      res.code === 200
        ? {
            success: true,
            code: res?.code,
            data: res.data,
            message: "成功",
          }
        : {
            success: true,
            code: res?.code,
            data: null,
            message: "查询失败",
          };
  }
};

module.exports = {servesRes}